<h2> Editar Solicitud de Pre Registro</h2>
<% if flash[:notice] %>
    <div id="notice"><%= flash[:notice] %></div>
<% end %>
<!-- Cada uno de los fields tiene 2 cosas: el span (label) + el campo, pero el campo esta oculto -->
<%= fields_for @cultural_heritage_pre_register_request do |f| %>

  <div class="shadow">
  <fieldset id="agrupacion" >
    <legend>Datos de Solicitud</legend>

       
       <fieldset class="column-left">
       <label>  Solicitud SOLPRE0<%= @cultural_heritage_pre_register_request.id %></label>

         <div class="field"
          <label>Usuario Creador</label>
             <%= @cultural_heritage_pre_register_request.str_user %>
              </div>

        <div class="field">
           <label>Fecha de Envio</label>
           <%= f.datepicker 'send_date'%>
        </div>

        <div class="field">
           <label>Fecha de Creación</label>
           <%= f.datepicker 'created_at'%>
         </div>
      </fieldset>

     <fieldset class="column-right">

       <br/>
     
     

          <div class="field">
          <label>Descripción:</label>
          <%= f.text_area :description %>
      </div>

     </fieldset>
  </fieldset>
  </div>
<div class="shadow">
<fieldset id="agrupacion" >
   <legend>Pre-Registros de Solicitud</legend>
<%#*<div class="field">%>
    <%#= f.label :send_date, "Fecha de Envio:" %>
    <%#*<!-- La clase q empieza con js_ se utiliza en el application.js y se oculta el input-->%>
    <%#*<span class="js_change_field_send_date editable_input"><%= @cultural_heritage_pre_register_request.send_date %>
<%#*</span>%>
    <%#= f.text_field :send_date, :style=>"display:none" %>
  <%#*</div>%>
  <%#*<div class="field">%>
    <%#= f.label :state, "Estado:" %>
    <%# state = @cultural_heritage_states.detect { |t| t.id == @cultural_heritage_pre_register_request.state } %>
    <%#*<span class="js_change_field_state editable_input"><%= state.name %>
<%#*</span>%>
    <%#= f.select :state,@cultural_heritage_states.collect {|t| [t.name,t.id]},{:include_blank=>"Seleccione"},{:style=>"display:none"} %>
  <%#*</div>%>
  <%#*<div class="field">%>
    <%#= f.label :description,"Descripcion:" %>
    <%#*<span class="js_change_field_description editable_input"><%= @cultural_heritage_pre_register_request.description %>
<%#*</span>%>
    <%#= f.text_area :description, :style=>"display:none" %>
  <%#*</div>%>

<p id="pre_register_reg_code" class="two-col"><label>Codigo de Registro:  </label><%= text_field_tag "search_input" %></p>

  
  <%= link_to "Agregar Nuevos Pre-Registro",:action=>"step_pre_register",:id=>@cultural_heritage_pre_register_request.id %>
  <br/>
  <!-- Tabla de elementos agregados hasta ahora-->
  <% if @list_pre_registers.length > 0 %>
    <table id="pre_registers_table_edit" class="paginated_table sorted_table">
      <thead>
      <tr>
        <br></br>
        <th>Nombre</th>
        <th>Grupo</th>
        <th>Periodo</th>
        <th>Tipologia</th>
       <th>Est conservacion</th>
        <th>Propietario</th>
        <%#*<th>Autor</th>%>
        <th>Acciones</th>
      </tr>
</thead>
      <% @list_pre_registers.each do |pre_register| %>
        <tr>
        
          <td><%= pre_register.name %></td>
          <td><%= pre_register.str_group%></td>
          <td><%= pre_register.str_period %></td>
          <td><%= pre_register.str_conservationalState %></td>
          <td><%= pre_register.str_tipology %></td>
          <td><%= pre_register.str_owner %></td>
          <%#*<td><%= pre_register.str_author %>
          <td>

               <%= link_to image_tag("navi/search-16-ns.png", :border => 0, :title => 'Mostrar'), {:action =>'show_pre_register',:id => pre_register.id}%>
      <% if (pre_register.state==nil) %>
          <%= link_to image_tag("navi/pencil-16-ns.png", :border => 0, :title => 'Editar'), {:action => 'edit_pre_register',:id => pre_register.id}%>

          <%= link_to image_tag("navi/cross-16-ns.png", :border => 0, :title => 'Eliminar'), {:action=>"delete_pre_register", :id=>pre_register.id}, {:method=>:delete, :confirm=>"Esta seguro de que desea eliminar este pre-registro?"}%>
       <% if (pre_register.group==1) %>
      <%= link_to image_tag("navi/badge-square-check-16-ns.png", :border => 0, :title => 'Aprobar'), {:controller=>"cultural_heritage/cultural_heritages", :action =>'approve',:id => pre_register.id, :search_input => "replace_user_id"}, {:confirm => '¿Realmente desea aprobar este Pre-registro?', :class=>"approve_pre_registers"}%>
      <% else %>
           <%= link_to image_tag("navi/badge-square-check-16-ns.png", :border => 0, :title => 'Aprobar'), {:controller=>"cultural_heritage/cultural_heritage_properties", :action =>'approve',:id => pre_register.id, :search_input => "replace_user_id"}, {:confirm => '¿Realmente desea aprobar este Pre-registro?', :class=>"approve_pre_registers_properties"}%>
      <% end %>
              <% end %>
            </td>
        </tr>
      <% end %>
    </table>
  <% else %>
    <p>No ha agregado ningun Pre-registro aun</p>
    <br/>
  <% end %>
   
   </fieldset>
  </div>


  <div class="actions">
        <%= f.submit "Guardar" %>
  </div>
<% end %>

<%#= link_to 'Mostrar', @cultural_heritage_pre_register_request %> 
<%= link_to 'Regresar', cultural_heritage_pre_register_requests_path %>


<script type="text/javascript">
 // form validation function //
 function validate(form) {

   var code = form.pre_register_reg_code.value;

   //Validaciones
    if(code == "") {
     inlineMsg('pre_register_reg_code','Debe ingresar un codigo para la aprobacion.',3);
     return false;
    }


 }
 </script>